feat: Browser Fetch API Compatibility v0.7.0 #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Browser Fetch API Compatibility v0.7.0
🎯 Overview
This PR implements Browser Fetch API compatibility for the HTTP Fetch library, achieving ~85% API parity with JavaScript's Fetch API.
✨ Features Added
Response Properties (Browser API Standard)
status_text- Status message ("OK", "Not Found", etc.)ok- Boolean for success status (200-299)body_used- Body consumption trackingredirected- Redirect detectiontype- Response type (:basic,:cors,:error,:opaque)Response Methods
Response.new/1- Constructor with auto-populated Browser API fieldsResponse.clone/1- Clone for multiple readsResponse.arrayBuffer/1- Read as binary (ArrayBuffer equivalent)Response.blob/1- Read as Blob with metadataNew Modules
HTTP.StatusText- 60+ status code mappingsHTTP.Blob- Blob struct with data, type, and sizeResponse Struct Fields Added
Five new fields:
status_text,ok,body_used,redirected,typeMigration
Pattern matches need updating:
📊 Test Coverage
🔍 Files Changed
lib/http/blob.ex,lib/http/status_text.ex, tests🎯 Browser API Usage Examples
✅ Checklist
API Parity: ~85% Browser Fetch API compatibility 🎉